/* Sentinel - IRC Statistical and Operator Services
** ircdsup.c - Sentinel ircd related supplemental functions.
**
** Copyright W. Campbell and others.  See README for more details
** Some code Copyright: Jonathan George, Kai Seidler, ircd-hybrid Team,
**                      IRCnet IRCD developers.
**
** $Id: ircdsup.c 7 2010-02-01 19:17:42Z dubkat $
*/

#include "stats.h"
#include "struct.h"
#include "proto.h"

void introduce_nick(char *nick, char *username, char *hostname, char *gecos,
                    char *modes)
{
#ifdef USE_CURRENT_TS

  time_t now = CurrentTime;
#else

  time_t now = 1;
#endif

#if defined(IRCD_HYBRID) || defined(IRCD_HYB6) || defined(IRCD_HYB7) || \
    defined(IRCD_HYBSVS)

  sts("NICK %s 1 %ld +%s %s %s %s :%s",
      nick, now, modes, username, hostname, settings.name, gecos);
#elif defined(IRCD_BAHAMUT)

  sts("NICK %s 1 %ld +%s %s %s %s 1 0 :%s",
      nick, now, modes, username, hostname, settings.name, gecos);
#endif
}

void set_oper(struct User *u, unsigned int flag, unsigned int operflag)
{
  IncreaseOpers(u->server);
  u->flags |= flag;
#ifdef OPER_MODES

  u->operflags |= operflag;
#endif

  AddOperToList(&global_oper_list, u);
}

void join_channel(char *channel, struct User *u, unsigned int flag)
{
  struct Channel *c;

  sts(":%s SJOIN %ld %s + :@%s", settings.name, CurrentTime, channel, u->nick);

  c = findchannel(channel);
  if (c == NULL)
    c = AddChannel(channel, CurrentTime);

  AddUserFlagToChannel(c, u, flag);
}
